<template>
  <div id="app">
    <nav v-if="!$route.query.flag">
      <!-- <router-link to="/">Home</router-link> |
      <router-link to="/about">About</router-link> |
      <router-link to="/admin">admin</router-link> |
      <router-link to="/user">user</router-link> -->
      <span v-for="item in menuList" :key="item.path">
        <router-link :to="item.path">{{ item.name }}</router-link> |
      </span>
    </nav>
    <router-view />
  </div>
</template>
<script>
export default {
  data() {
    return {
      menuList: [] // 菜单列表
    }
  },
  mounted() {
    // 根据当前用户权限生成菜单
    const permission = ['admin', 'user'] // 假设当前用户权限为 admin 或 user
    console.log(this.$router, 'router')
    this.menuList = this.$router.options.routes.filter(route => {
      return route.meta && route.meta.permission.includes('user')
    }).map(route => {
      return {
        name: route.name,
        path: route.path
      }
    }).slice(0, this.menuList.length - 1) // 去掉404页面
    console.log(this.menuList, 'menu')
    console.log(process.env)
    console.log(process.env.NODE_ENV)
  },
  methods: {
   
  }
}
</script>
<style lang="scss" scoped>
nav {
  padding: 30px;
  text-align: center;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
